package com.geektime.tdd.tdd;

import java.util.List;
import java.util.function.Function;

class SingleValuedOptionParser implements OptionParse {

    Function<String, Object > function;

    public SingleValuedOptionParser(Function<String, Object > function) {
        this.function = function;
    }

    @Override
    public Object  parse(List<String> argments, Option option) {
        int index = argments.indexOf("-" + option.value());
        String value = argments.get(index + 1);
        return function.apply(value);
    }


}
